home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------------
- ;File name: URAn_DOS.SH Revision date: 1997.08.10
- ;Creator: Ulf Ronald Andersson Creation date: 1991.01.02
- ;(c)1991 by: Ulf Ronald Andersson All rights reserved
- ;Released as: FREEWARE (commercial sale forbidden)
- ;----------------------------------------------------------------------------
- ;Purpose: Symbol & Macro library for GEMDOS, XBIOS, and BIOS functions
- ;----------------------------------------------------------------------------
- ;Required header declarations:
- ;
- ; include "uran\STRUCT.SH"
- ; include "uran\URAn_SYS.SH"
- ; include "uran\URAn_DOS.SH"
- ;
- ;----------------------------------------------------------------------------
- ; GEMDOS DEFINITIONS
- ;
- ;trap<<20 + args<<16 + ptrbits<<12 + longbits<<8 + opcode
- ;
- Pterm0 equ $100000
- Cconin equ $100001
- Cconout equ $110002
- Cauxin equ $100003
- Cauxout equ $110004
- Cprnout equ $110005
- Crawio equ $110006
- Crawcin equ $100007
- Cnecin equ $100008
- Cconws equ $111009
- Cconrs equ $11100A
- Cconis equ $10000B
- Dsetdrv equ $11000E
- Cconos equ $100010
- Cprnos equ $100011
- Cauxis equ $100012
- Cauxos equ $100013
- ; Maddalt equ $14 ;???
- Dgetdrv equ $100019
- Fsetdta equ $11101A
- Super equ $111020
- Tgetdate equ $10002A
- Tsetdate equ $11002B
- Tgettime equ $10002C
- Tsettime equ $11002D
- Fgetdta equ $10002F
- Sversion equ $100030
- Ptermres equ $120131
- Dfree equ $121036
- Dcreate equ $111039
- Ddelete equ $11103A
- Dsetpath equ $11103B
- Fcreate equ $12103C
- Fopen equ $12103D
- Fclose equ $11003E
- Fread equ $13423F
- Fwrite equ $134240
- Fdelete equ $111041
- Fseek equ $130142
- Fattrib equ $131043
- Mxalloc equ $120144 ;very modern TOS only
- Fdup equ $110045
- Fforce equ $120046
- Dgetpath equ $121047
- Malloc equ $110148
- Mfree equ $111049
- Mshrink equ $13244A
- Pexec equ $14E04B
- Pterm equ $11004C
- Fsfirst equ $12104E
- Fsnext equ $10004F
- Frename equ $136056
- Fdatime equ $131057
- ;
- ;
- ;----------------------------------------------------------------------------
- ; BIOS DEFINITIONS
- ;
- ;trap<<20 + args<<16 + ptrbits<<12 + longbits<<8 + opcode
- ;
- Getmpb equ $D11000
- Bconstat equ $D10001
- Bconin equ $D10002
- Bconout equ $D20003
- Rwabs equ $D52004
- Setexc equ $D22005
- Tickal equ $D00006
- Getbpb equ $D10007
- Bcostat equ $D10008
- Mediach equ $D10009
- Drvmap equ $D0000A
- Kbshift equ $D1000B
- ;
- ;
- ;----------------------------------------------------------------------------
- ; XBIOS DEFINITIONS
- ;
- ;trap<<20 + args<<16 + ptrbits<<12 + longbits<<8 + opcode
- ;
- Initmous equ $E36000
- Ssbrk equ $E20001
- Physbase equ $E00002
- Logbase equ $E00003
- Getrez equ $E00004
- Setscreen equ $E33005
- Setpallete equ $E11006
- Setpalette equ $E11006
- Setcolor equ $E20007
- Floprd equ $E71208
- Flopwr equ $E71209
- Flopfmt equ $E71F0A
- ;; CLR_D0 equ $E0000B
- Midiws equ $E2200C
- Mfpint equ $E2200D
- Iorec equ $E1000E
- Rsconf equ $E6000F
- Keytbl equ $E37010
- Random equ $E00011
- Protobt equ $E41212
- Flopver equ $E71213
- Scrdmp equ $E00014
- Cursconf equ $E20015
- Settime equ $E10116
- Gettime equ $E00017
- Bioskeys equ $E00018
- Ikbdws equ $E22019
- Jdisint equ $E1001A
- Jenabint equ $E1001B
- Giaccess equ $E2001C
- Offgibit equ $E1001D
- Ongibit equ $E1001E
- Xbtimer equ $E4801F
- Dosound equ $E11020
- Setprt equ $E10021
- Kbdvbase equ $E00022
- Kbrate equ $E20023
- Prtblk equ $E11024
- Vsync equ $E00025
- Supexec equ $E11026
- Puntaes equ $E00027
- Floprate equ $E20029 ;STE & Rainbow TOS
- ;-------------------------------------
- ; Dmaread equ $E4412A ;=> E_INVFN if absent
- ; Dmawrite equ $E4412B ;=> E_INVFN if absent
- ;-------------------------------------
- Bconmap equ $E1002C ;-2=>struct -1=>currdev 0=>test 6=>ST-port 7=>SCC_B 8=>TTMFP 9=>SCC_A
- ;-------------------------------------
- ; Nvmaccess equ $2E ;???
- ;-------------------------------------
- ;0 VOID Metainit ( META_INFO_1 *buffer );
- ;1 LONG Metaopen ( SHORT drive, META_DRVINFO *buffer );
- ;2 LONG Metaclose ( SHORT drive );
- ;3 LONG Metaread ( SHORT drive, VOID *buffer, LONG blockno, SHORT count );
- ;4 LONG Metawrite ( SHORT drive, VOID *buffer, LONG blockno, SHORT count );
- ;5
- ;6 LONG Metastatus ( SHORT drive, VOID *buffer );
- ;7 LONG Metaioctl ( SHORT drive, LONG magic, SHORT opcode, VOID *buffer );
- ;8
- ;9
- ;A
- ;B LONG Metastartaudio ( SHORT drive, SHORT flag, UBYTE *bytes_p);
- ;C LONG Metastopaudio ( SHORT drive );
- ;D LONG Metasetsongtime (SHORT drive,SHORT repeat,LONG starttime,LONG endtime );
- ;E LONG Metagettoc ( SHORT drive, SHORT flag, CD_TOC_ENTRY *buffer );
- ;F LONG Metadiscinfo ( SHORT drive, CD_DISC_INFO *p );
- ;-------------------------------------
- Metainit equ $E11030
- Metaopen equ $E22031
- Metaclose equ $E10032
- Metaread equ $E42433
- Metawrite equ $E42434
- ;code $35 is unknown
- Metastatus equ $E22036
- Metaioctl equ $E48237
- ;code $38 is unknown
- ;code $39 is unknown
- ;code $3A is unknown
- Metastartaudio equ $E3403B ;use: flag=0 bytes_p[2]={songs,startsong}
- Metastopaudio equ $E1003C
- Metasetsongtime equ $E40C3D
- Metagettoc equ $E3403E
- Metadiscinfo equ $E2203F
- ;-------------------------------------
- Blitmode equ $E10040 ;all late TOS
- ; Esetshift equ $50 ;???
- ; Egetshift equ $51 ;???
- Esetbank equ $E10052 ;TT ?
- ; Esetcolor equ $53 ;???
- ; Esetpalette equ $54 ;???
- ; Egetpalette equ $55 ;???
- Esetgray equ $E10056 ;TT ?
- ; Esetsmear equ $57 ;???
- ; ??? ? $58 ;??? Used by NVDI
- ;
- ;----------------------------------------------------------------------------
- ; Error code definitions
- ;
- E_OK equ 0
- E_ERROR equ -1
- E_DRVNR equ -2
- E_UNCMD equ -3
- E_CRC equ -4
- E_BADRQ equ -5
- E_SEEK equ -6
- E_MEDIA equ -7
- E_SECNF equ -8
- E_PAPER equ -9
- E_WRITF equ -10
- E_READF equ -11
- E_WRPRO equ -12
- ; ??? equ -13
- E_CHNG equ -14
- E_UNDEV equ -15
- E_BADSF equ -16
- E_OTHER equ -17
- ;
- ; --------
- ;
- E_INVFN equ -32
- E_FILNF equ -33
- E_PTHNF equ -34
- E_NHNDL equ -35
- E_ACCDN equ -36
- E_IHNDL equ -37
- ; ??? equ -38
- E_NSMEM equ -39
- E_IMBA equ -40
- ; ??? equ -41
- E_DFULL equ -42
- ; ??? equ -43
- ; ??? equ -44
- ; ??? equ -45
- E_DRIVE equ -46
- ; ??? equ -47
- E_NSAME equ -48
- E_NMFIL equ -49
- ;
- ; --------
- ;
- E_RANGE equ -64
- E_NAMETOOLONG equ E_RANGE
- E_INTRN equ -65
- E_PLFMT equ -66
- E_GSBF equ -67
- ;
- ; --------
- ;
- E_LOCK equ -58 ;NB: changed from E_LOCKED due to STiK symbol
- E_NSLOCK equ -59
- E_LOOP equ -80
- E_MOUNT equ -200
- ;
- ;
- ;----------------------------------------------------------------------------
- ; Boot sector offsets
- ;
- struct boot_sector
- d_w bs_codebra ;$00 w $60xx
- d_s bs_filler,6 ;$02 6b
- d_s bs_serial,3 ;$08 3b
- d_ow bs_sectbytes ;$0b iw
- d_b bs_clust_sects ;$0d b
- d_ow bs_boot_sects ;$0e iw
- d_b bs_disk_FATs ;$10 b
- d_ow bs_root_files ;$11 iw
- d_ow bs_disk_sects ;$13 iw
- d_b bs_media ;$15 b
- d_w bs_FAT_sects ;$16 iw
- d_w bs_track_sects ;$18 iw
- d_w bs_disk_sides ;$1a iw
- d_w bs_hide_sects ;$1c iw
- ; next follows the part used only by executable boots
- d_alias bs_textbeg ;$1e program
- ; next follow definitions used only by executable boots of a special kind
- d_w bs_execflg ;$1e w
- d_w bs_ldmode ;$20 w
- d_w bs_ssect ;$22 w
- d_w bs_sectcnt ;$24 w
- d_l bs_ldaddr ;$26 L
- d_l bs_fatbuf ;$2a L
- d_s bs_fname,11 ;$2e 11b
- d_b bs_fname_end ;$39 b
- d_s bs_bootprog,512-bs_bootprog ;$3a .. $1ff
- d_end boot_sector
- ;
- ;
- ;----------------------------------------------------------------------------
- ; BPB offsets
- ;
- struct bpb_struct
- d_w bpb_sect_bytes ;typ: 512
- d_w bpb_clust_sects ;typ: 2
- d_w bpb_clust_bytes ;typ: 1024
- d_w bpb_root_sects ;typ: 7
- d_w bpb_FAT_sects ;typ: 5
- d_w bpb_FAT2_start ;typ: 6
- d_w bpb_data_start ;typ: 18 = 2*5 + 7 + 1
- d_w bpb_data_clusts ;typ: 711 = 720 - 18/2
- d_w bpb_flag ;b0==16bit_FAT/12bit_FAT typ: 0
- d_alias bpb_size
- d_end bpb_struct
- ;
- ;NB: data_start = FAT_sects*2 + root_sects + 1 rounded up for clust_sects alignment
- ;NB: data_clusts= Total_clusts - data_start/clust_sect
- ;
- ;
- ;----------------------------------------------------------------------------
- ; Directory offsets
- ;
- struct dir_struct
- d_s dir_fname,8 ;first char $00==unused $E5==erased
- d_s dir_fext,3
- d_b dir_fattr
- d_s dir_reserved,10
- d_w dir_ftime ;iw
- d_w dir_fdate ;iw
- d_w dir_fcluster ;iw
- d_l dir_fsize ;il
- d_alias dir_size
- d_end dir_struct
- ;
- ;
- ;----------------------------------------------------------------------------
- ; DTA offsets
- ;
- struct dta_struct
- d_s dta_gname,12
- d_l dta_drive
- d_w dta_dbpos
- d_w dta_dsec0
- d_b dta_gattr
- d_b dta_fattr
- d_w dta_ftime
- d_w dta_fdate
- d_l dta_fsize
- d_s dta_fname,14
- d_alias dta_size
- d_end dta_struct
- ;
- ;
- ;----------------------------------------------------------------------------
- ; Program file header offsets
- ;
- struct program_header
- d_w ph_codebra ;always $601A
- d_l ph_textlen
- d_l ph_datalen
- d_l ph_bss_len
- d_l ph_symblen
- d_l ph_res1
- d_alias ph_flag ;only TOS >= 1.4: bit 0 == fastload
- d_l ph_res2
- d_w ph_res3
- d_alias ph_textbeg
- d_alias ph_size
- d_end program_header
- ;
- ;
- ;----------------------------------------------------------------------------
- ; Buffer Control Block offsets
- ;
- struct bcb_struct
- d_l bcb_link_p
- d_w bcb_drive
- d_w bcb_type
- d_w bcb_record
- d_w bcb_dirty
- d_l bcb_dm_p
- d_l bcb_data_p
- d_alias bcb_size
- d_end bcb_struct
- ;
- ;
- ;----------------------------------------------------------------------------
- ; Basepage offsets
- ;
- struct basepage
- d_l bp_selfbeg_p
- d_l bp_selfend_p
- d_l bp_textbeg_p
- d_l bp_textlen
- d_l bp_databeg_p
- d_l bp_datalen
- d_l bp_bss_beg_p
- d_l bp_bss_len
- d_l bp_dta_p
- d_l bp_parent_p
- d_l bp_reserved
- d_l bp_environ_p
- d_s bp_undef,80
- d_b bp_arglen
- d_s bp_argstring,127
- d_end basepage
- ;
- ;
- ;----------------------------------------------------------------------------
- ; MACRO DEFINITIONS
- ;
- MACRO gemdos op,v2,v3,v4,v5
- zz_prep_trap op,v2,v3,v4,v5
- trap #zzDOSTR
- ifne op-Pterm0
- ifne op-Pterm
- ifne op-Ptermres
- ifne (zzDOSAS>0)&(zzSTkeep=0)
- ifne (zzDOSAS>8)|zzDUMBcomp
- lea zzDOSAS(sp),sp
- else
- addq #zzDOSAS,sp
- endif
- endif
- endif
- endif
- endif
- ENDM
- ;
- MACRO sub_gemdos op,v2,v3,v4,v5
- zz_prep_trap op,v2,v3,v4,v5
- bsr gemdos_sub
- ifne op-Pterm0
- ifne op-Pterm
- ifne op-Ptermres
- ifne (zzDOSAS>0)&(zzSTkeep=0)
- ifne (zzDOSAS>8)|zzDUMBcomp
- lea zzDOSAS(sp),sp
- else
- addq #zzDOSAS,sp
- endif
- endif
- endif
- endif
- endif
- ENDM
- ;
- MACRO bios op,v2,v3,v4,v5,v6
- xbios op,v2,v3,v4,v5,v6
- ENDM
- ;
- MACRO sub_bios op,v2,v3,v4,v5,v6
- zz_prep_trap op,v2,v3,v4,v5,v6
- bsr bios_sub
- ifne (zzDOSAS>0)&(zzSTkeep=0)
- ifne (zzDOSAS>8)|zzDUMBcomp
- lea zzDOSAS(sp),sp
- else
- addq #zzDOSAS,sp
- endif
- endif
- ENDM
- ;
- MACRO xbios op,v2,v3,v4,v5,v6,v7,v8,v9,va
- zz_prep_trap op,v2,v3,v4,v5,v6,v7,v8,v9,va
- trap #zzDOSTR
- ifne (zzDOSAS>0)&(zzSTkeep=0)
- ifne (zzDOSAS>8)|zzDUMBcomp
- lea zzDOSAS(sp),sp
- else
- addq #zzDOSAS,sp
- endif
- endif
- ENDM
- ;
- MACRO sub_xbios op,v2,v3,v4,v5,v6,v7,v8,v9,va
- zz_prep_trap op,v2,v3,v4,v5,v6,v7,v8,v9,va
- bsr xbios_sub
- ifne (zzDOSAS>0)&(zzSTkeep=0)
- ifne (zzDOSAS>8)|zzDUMBcomp
- lea zzDOSAS(sp),sp
- else
- addq #zzDOSAS,sp
- endif
- endif
- ENDM
- ;
- MACRO zz_prep_trap op,v2,v3,v4,v5,v6,v7,v8,v9,va
- zzDOSIF set (op)&_ind
- zzDOSTR set ((op)>>20)&255
- zzDOSAC set ((op)>>16)&15
- zzDOSPF set ((op)>>12)&15
- zzDOSLF set ((op)>>08)&15
- zzDOSOP set (op)&255
- zzDOSAS set -zzSToff
- IFNE zzDOSAC>0
- IFNE zzDOSAC>1
- IFNE zzDOSAC>2
- IFNE zzDOSAC>3
- IFNE zzDOSAC>4
- IFNE zzDOSAC>5
- IFNE zzDOSAC>6
- IFNE zzDOSAC>7
- IFNE zzDOSAC>8
- IFNE zzDOSLF=15
- zzDOSLF set 130
- endif
- DOSPUSH 8,va
- endif
- DOSPUSH 7,v9
- endif
- DOSPUSH 6,v8
- endif
- DOSPUSH 5,v7
- endif
- DOSPUSH 4,v6
- endif
- DOSPUSH 3,v5
- endif
- DOSPUSH 2,v4
- endif
- DOSPUSH 1,v3
- endif
- DOSPUSH 0,v2
- endif
- zzDOSAS set zzDOSAS+2
- ifne 1&zzDOSAS
- .error "Stack offset is odd"
- endif
- ifgt zzDOSAS
- MOVE #zzDOSOP,-(sp)
- else
- ifeq zzDOSAS
- move #zzDOSOP,(sp)
- else
- .error "Stack offset is too large"
- endif
- endif
- ENDM
- ;
- ;This macro handles all argument checking for bios, xbios & gemdos functions
- ;special argument cases are:
- ;no argument = .error error
- ;'()' = Assumes argument is on stack already
- ;'!' = Places 0 on stack using "clr"
- ;'?' = Places -1 on stack
- MACRO DOSPUSH v1,v2
- zzDOSAS set zzDOSAS+2
- IFNE (1<<v1)&(zzDOSPF|zzDOSLF)
- zzDOSAS set zzDOSAS+2
- endif
- ifne 1&zzDOSAS
- .error Stack offset is odd
- endif
- IFB v2
- .error "Missing operand in system call"
- exitm
- endif
- ifgt zzDOSAS
- IFNE (1<<v1)&zzDOSPF
- iflt zzDOSAS-4
- .error "Pointer argument crosses stack offset"
- endif
- IFEQ zzDOSIF
- pea v2
- exitm
- endif
- move.l v2,-(sp)
- exitm
- endif ;ends pointer case
- IFNE (1<<v1)&zzDOSLF
- iflt zzDOSAS-4
- .error "Long argument crosses stack offset"
- endif
- move.l v2,-(sp)
- exitm
- endif ;ends long case
- move v2,-(sp) ;ends word case
- exitm
- else ;start stack offset cases
- ifeq zzDOSAS
- IFNE (1<<v1)&zzDOSPF
- IFEQ zzDOSIF
- addq #4,sp
- pea v2
- exitm
- endif
- move.l v2,(sp)
- exitm
- endif ;ends pointer case
- IFNE (1<<v1)&zzDOSLF
- move.l v2,(sp)
- exitm
- endif ;ends long case
- move v2,(sp) ;ends word case
- exitm
- else ;handle negative offset levels
- IFNE (1<<v1)&zzDOSPF
- IFEQ zzDOSIF
- move.l #v2,-zzDOSAS(sp)
- exitm
- endif
- move.l v2,-zzDOSAS(sp)
- exitm
- endif ;ends pointer case
- IFNE (1<<v1)&zzDOSLF
- move.l v2,-zzDOSAS(sp)
- exitm
- endif ;ends long case
- move v2,-zzDOSAS(sp) ;ends word case
- exitm
- endif
- endif
- ENDM
- ;
- zzDOSAS set 0
- zzSToff set 0
- zzSTkeep set 0
- zzDUMBcomp set 0
- ;
- ;----------------------------------------------------------------------------
- ;End of file: URAn_DOS.SH
- ;----------------------------------------------------------------------------
-